﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'P_GetBasicReferenceFiles')
	BEGIN
		DROP  Procedure  esf_sso.P_GetBasicReferenceFiles
	END
GO

CREATE Procedure esf_sso.P_GetBasicReferenceFiles
(
	@pBasicReferenceID		BIGINT
)
AS

	SELECT
		F.ID			File_ID
		,F.URL			File_URL
		,F.Description	File_Description
		,VFC.ID			File_FilCat_ID
		,VFC.Code		File_FilCat_Code
		,VFC.Name		File_FilCat_Name
	FROM
		esf_sso.BasicReference_File BRF
	INNER JOIN
		esf_files.[FileReference] F ON F.ID = BRF.FileID 
	LEFT JOIN
		esf_sso.VFileCategory VFC ON VFC.ID = F.FileTypeID
	WHERE
		BRF.BasicReferenceID = @pBasicReferenceID

GO